package com.simple.dispatcher.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.simple.dispatcher.service.DispatcherService;
import com.simple.dispatcher.servlet.utils.RequestParamUtils;

@Controller
public class DeleteUserFilterServlet {
	
	@Autowired
	private DispatcherService dispatcherService;

	@RequestMapping("/deletefilter.do")
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		long userId = RequestParamUtils.getLongValue(req, "uid", 0L);
		if(userId != 0L){
			dispatcherService.deleteUserFilter(userId);
			resp.setStatus(HttpServletResponse.SC_OK);
			return;
		}
		resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
